package com.pond.pond.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.pond.pond.domain.vo.FishTypeOptionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pond.common.log.annotation.Log;
import com.pond.common.log.enums.BusinessType;
import com.pond.common.security.annotation.RequiresPermissions;
import com.pond.pond.domain.FishType;
import com.pond.pond.service.IFishTypeService;
import com.pond.common.core.web.controller.BaseController;
import com.pond.common.core.web.domain.AjaxResult;
import com.pond.common.core.utils.poi.ExcelUtil;
import com.pond.common.core.web.page.TableDataInfo;

/**
 * 鱼种类Controller
 * 
 * @author ruoyi
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/fishtype")
public class FishTypeController extends BaseController
{
    @Autowired
    private IFishTypeService fishTypeService;

    /**
     * 查询鱼种类列表
     */
    @RequiresPermissions("pond:fishtype:list")
    @GetMapping("/list")
    public TableDataInfo list(FishType fishType)
    {
        startPage();
        List<FishType> list = fishTypeService.selectFishTypeList(fishType);
        return getDataTable(list);
    }

    /**
     * 查询鱼种类列表
     */
    @GetMapping("/fish-options")
    public TableDataInfo list()
    {
        startPage();
        List<FishTypeOptionsVo> list = fishTypeService.selectFishTypeOptionList();
        return getDataTable(list);
    }

    /**
     * 导出鱼种类列表
     */
    @RequiresPermissions("pond:fishtype:export")
    @Log(title = "鱼种类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishType fishType)
    {
        List<FishType> list = fishTypeService.selectFishTypeList(fishType);
        ExcelUtil<FishType> util = new ExcelUtil<FishType>(FishType.class);
        util.exportExcel(response, list, "鱼种类数据");
    }

    /**
     * 获取鱼种类详细信息
     */
    @RequiresPermissions("pond:fishtype:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishTypeService.selectFishTypeById(id));
    }

    /**
     * 新增鱼种类
     */
    @RequiresPermissions("pond:fishtype:add")
    @Log(title = "鱼种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishType fishType)
    {
        return toAjax(fishTypeService.insertFishType(fishType));
    }

    /**
     * 修改鱼种类
     */
    @RequiresPermissions("pond:fishtype:edit")
    @Log(title = "鱼种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishType fishType)
    {
        return toAjax(fishTypeService.updateFishType(fishType));
    }

    /**
     * 删除鱼种类
     */
    @RequiresPermissions("pond:fishtype:remove")
    @Log(title = "鱼种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishTypeService.deleteFishTypeByIds(ids));
    }
}
